package cn.hp.controller;

import cn.hp.entity.UserRole;
import cn.hp.service.UserRoleSerivce;
import cn.hp.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/userRole")
public class UserRoleController {

    @Autowired
    private UserRoleSerivce userRoleSerivce;

    @GetMapping("/getUserRole")
    public Object getUserRole(UserRole obj) {
        List<UserRole> list=userRoleSerivce.selectUserRoleList(obj);
        String [] roleIds=new String[list.size()];
        for (int i = 0; i < list.size(); i++) {
            UserRole userRole=list.get(i);
            roleIds[i]=userRole.getRoleId()+":"+userRole.getDescription();
        }
        return Result.success(roleIds);
    }
}
